//index.js
var app = getApp()
Page({
  data: {
    navindex: 0,
    nav: [
      { txt: '未派单' },
      { txt: '已派单' },
      
    ],
    orderdeil: [
      {
        urls: "../../images/banner1.jpg",
        name: "需使用4G飞享套餐。赠送12GB流量，2400分钟通话",
        price: "1370",
        shuliang: "1",
        allprice: '300.00',
        state: '已派单',
        number: '333658987',
      },
      {
        urls: "../../images/banner1.jpg",
        name: "需使用4G飞享套餐。赠送12GB流量，2400分钟通话",
        price: "1370",
        shuliang: "1",
        allprice: '300.00',
        state: '未派单',
        date: '2016-03-06 11:26',
        number: '5',
      },

    ],
    indicatorDots: true,
    autoplay: true,
    interval: 5000,
    duration: 1000,
    userInfo: {}
  },
  click: function (e) {
    var id = e.currentTarget.dataset.id;
    console.log(id)
    this.setData({
      navindex: id
    })
    // wx.request({
    //   url: 'https://yunying.135k.com/api/goods/myposs',
    //   data: {
    //   },
    //   success: function (res) {
    //     that.setData({
    //       list: res.data.data
    //     })
    //   }
    // })
  },
  toOrder: function () {
    app.navTo('../order/order')
  },
  modalcnt: function (e) {
    var id = e.currentTarget.id;
    var del = this.data.orderdeil;
    var that = this;
    wx.showModal({
      title: '提示',
      content: '确定要删除当前订单吗？',
      success: function (res) {
        if (res.confirm) {
          // console.log('用户点击确定')
          for (var i in del) {
            if (i == id) {
              del.splice(id, 1);
            }
          }
          that.setData({
            orderdeil: del
          })
        } else if (res.cancel) {
          // console.log('用户点击取消')

        }
      }
    })
  },
  deleteList(e) {
    const index = e.currentTarget.dataset.index;
    let orderdeil = this.data.orderdeil;
    orderdeil.splice(index, 1);              // 删除购物车列表里这个商品
    this.setData({
      orderdeil: orderdeil
    });
    if (!carts.length) {                  // 如果购物车为空
      this.setData({
        hasList: false              // 修改标识为false，显示购物车为空页面
      });
    } else {                              // 如果不为空
      this.getTotalPrice();           // 重新计算总价格
    }
  },
  onLoad: function () {
    console.log('onLoad test');
  },

})  
